52
Inheritance in C++
 class Point3D : public Point {
    int _z;
 
  public:
    Point3D() {
      setX(0);
      setY(0);
      _z = 0;
    }
    Point3D(const int x, const int y, const int z) {
      setX(x);
      setY(y);
      _z = z;
    }
    ~Point3D() { /* Nothing to do */ }
    int getZ() { return _z; }
    void setZ(const int val) { _z = val; }
  };
“inherits from”
==
“:”
 In our pseudo language, we formulate inheritance with “inherits from''. In C++ these words are replaced by a colon. As an example let's design a class for 3D
points. Of course we want to reuse our already existing class Point.